﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

namespace TimeWar.Shared.Config
{
    public class TerrainConfig
    {
        // these variables store values that are accessible in game class
        public byte[]       height;
        public Vector3[]    position;
        public Vector3[]    normal;
        public int          NUM_ROWS, NUM_COLS;
        public float        worldWidth, worldHeight, heightScale;
        public float        cellWidth, cellHeight;

        //public float Position
        public TerrainConfig(ContentReader cr)
        {
            NUM_ROWS     = cr.ReadInt32();
            NUM_COLS     = cr.ReadInt32();
            worldWidth   = cr.ReadSingle();
            worldHeight  = cr.ReadSingle();
            heightScale  = cr.ReadSingle();
            cellWidth    = cr.ReadSingle();
            cellHeight   = cr.ReadSingle();
            
            // declare position and normal vector arrays
            position     = new Vector3[NUM_ROWS*NUM_COLS];
            normal       = new Vector3[NUM_ROWS*NUM_COLS];
            
            // read in position and normal data to generate height map
            for (int row = 0; row < NUM_ROWS; row++)
            {
                for (int col = 0; col < NUM_COLS; col++)
                {
                    position[col + row*NUM_COLS]  = cr.ReadVector3();
                    normal[col + row*NUM_COLS]    = cr.ReadVector3();
                }
            }
        }

    }
}
